﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>选择分类</title>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <script src="/Static/jquery-1.6.2.min.js" type="text/javascript"></script>
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    <script src="/Static/boot.js" type="text/javascript"></script>
    <link href="/Static/demo.css" rel="stylesheet" />
    <link href="/Static/miniui/themes/blue/skin.css" rel="stylesheet" />
    <style type="text/css">
        html, body {
            padding: 0;
            margin: 0;
            border: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
        }
    </style>
</head>
    <body>
        <div class="mini-toolbar" style="text-align:center;line-height:30px;"
             borderstyle="border-left:0;border-top:0;border-right:0;">
            <label>名称：</label>
            <input id="key" class="mini-textbox" style="width:150px;" onenter="Filtersearch()" />
            <a class="mini-button" style="width:60px;" onclick="Filtersearch()" plain="true">查询</a>
        </div>
        <div class="mini-fit">

            <ul id="tree_Organization" class="mini-tree" style="width:100%;height:100%;"
                showtreeicon="true" textfield="CategoryDisplayName" idfield="ID" parentfield="ParentCategoryID" resultastree="false"
                expandonload="true" onnodedblclick="onNodeDblClick" expandondblclick="false" enablehottrack="true"
                expandonnodeclick="true"></ul>

        </div>
        <div class="mini-toolbar" style="text-align:center;padding-top:8px;padding-bottom:8px;"
             borderstyle="border-left:0;border-bottom:0;border-right:0;">
            <a class="mini-button" style="width:60px;" onclick="onOk()">确定</a>
            <span style="display:inline-block;width:25px;"></span>
            <a class="mini-button" style="width:60px;" onclick="onCancel()">清空</a>
        </div>
    </body>
</html>
<script type="text/javascript">
    mini.parse();
    var tree = mini.get("tree_Organization");
    tree.load("/Ajax/AjaxService.aspx?method=GetCategory&pageSize=100000");

    function GetData() {
        var node = tree.getSelectedNode();
        return node;
    }
    function Filtersearch() {
        var key = mini.get("key").getValue();

        if (key == "") {
            tree.clearFilter();
        } else {
            //key = key.toLowerCase();
            tree.filter(function (node) {
                var text = node.CategoryDisplayName ? node.CategoryDisplayName.toLowerCase() : "";
                if (text.indexOf(key) != -1) {
                    return true;
                }
            });
        }
    }
    function onKeyEnter(e) {
        search();
    }
    function onNodeDblClick(e) {
        onOk();
    }
    //////////////////////////////////
    function CloseWindow(action) {
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();
    }

    function onOk() {
        var node = tree.getSelectedNode();
        CloseWindow("ok");
    }
    function onCancel() {
        //清空
        CloseWindow("clear");
    }
    /**通过父页面传递过来的参数设置树形的默认选择项**************************************************************/
    function SetDefaultSelect(data) {
        try {
            if (data) {
                tree.selectNode(data.ParentID);
                //试图滚动至选中项
                tree.expandPath(data.ParentID);
                tree.scrollIntoView(data.ParentID);
            }
        } catch (e) {

        }
    }


</script>